package com.cnzha.mr.order;

import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;


/**
 * @Author: zhaoxin
 * @email: zdkk@foxmail.com
 * @Date: 2020/4/4 23:24
 */
public class OrderSortGroupingComparator extends WritableComparator {

    protected OrderSortGroupingComparator() {
        super(OrderBean.class, true);
    }

    @Override
    public int compare(WritableComparable a, WritableComparable b) {
        OrderBean aOrder = (OrderBean) a;
        OrderBean bOrder = (OrderBean) b;

        int result = 0;

        if (aOrder.getOrderId() > bOrder.getOrderId()) {
            result = 1;
        } else if (aOrder.getOrderId() < bOrder.getOrderId()) {
            result = -1;
        } else {
            result = 0;
        }
        return result;
    }
}
